﻿#include "CameraControl.h"
#include<iostream>
CameraControl::CameraControl()
{
}

CameraControl::~CameraControl()
{
}

void CameraControl::update()
{
}

void CameraControl::onMouse(int button, int action, double xpos, double ypos)
{
	std::cout << "鼠标按下" << std::endl;
	bool pressed = action == GLFW_PRESS ? true : false;

	if (pressed) {
		mCurrentX = xpos;
		mCurrentY = ypos;
	}
	switch (button) {
	case GLFW_MOUSE_BUTTON_LEFT:
		mLeftMouseDown = pressed;
		break;
	case GLFW_MOUSE_BUTTON_RIGHT:
		mRightMouseDown = pressed;
		break;
	case GLFW_MOUSE_BUTTON_MIDDLE:
		mMiddleMouseDown = pressed;
		break;
	}
	
}

void CameraControl::onCursor(double xpos, double ypos)
{
	std::cout<<"鼠标移动"<<std::endl;
	mCurrentX = xpos;
	mCurrentY = ypos;
}

void CameraControl::onKey(int key, int action, int mods)
{
	std::cout << "action:"<<action << std::endl;
	//如果按下一个键不放松，action就会变成repeat一直重复，这里过滤掉repeat的情况
	if (action == GLFW_REPEAT)return;
	bool pressed = action == GLFW_PRESS ? true : false;
	mKeyMap[key] = pressed;
}

void CameraControl::onScroll(float offset)
{

}
